import java.util.Arrays;

/**
 * @Description
 */

public class MyStack {

    private int[] elem;
    int age;
    private static final int DEFAULT_SIZE = 10;
    private int usedSize;

    public MyStack(){
        elem = new int[DEFAULT_SIZE];

    }
    public void push(int val){
        if(isFull()){
            //扩容
            grow();
        }
        elem[usedSize] = val;
        usedSize++;
    }
    public boolean isFull(){
        return usedSize==DEFAULT_SIZE;
    }
    private void grow(){
        elem = Arrays.copyOf(elem,elem.length);
    }
    public int pop(){
        if(isEmpty()){
            return -1;
        }
        usedSize--;
        return elem[usedSize];
    }
    public int peek(){
        if(isEmpty()){
            return -1;
        }
        return elem[usedSize-1];
    }
    public boolean isEmpty() {
        return usedSize==0;
    }
}
